<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 初始化 */
        * {
            padding: 0;
            margin: 0;
        }

        li {
            list-style-type: none;
        }

        .shop-box {
            width: 360px;
            border: 1px solid #eee;
            margin: auto;
        }

        .big-img>img {
            width: 100%;
        }

        .small-img-list {
            display: flex;
        }

        .small-img-list li {
            width: 20%;
        }
/* 小图片的边框 */
        .cur-img {
            border: 2.5px solid red;
        }
    </style>
</head>

<body>

    <div class="shop-box">
        <div class="big-img">
            <img src="https://img14.360buyimg.com/n5/jfs/t1/38555/39/19176/66455/6335ccfcE492fb9a6/729aa1905c16c873.jpg"
                alt="">
        </div>
        <ul class="small-img-list">
            <li class="cur-img"><img
                    src="https://img14.360buyimg.com/n5/jfs/t1/38555/39/19176/66455/6335ccfcE492fb9a6/729aa1905c16c873.jpg.avif"
                    alt=""></li>
            <li><img src="https://img14.360buyimg.com/n5/jfs/t1/49010/21/18369/151736/628ddbe8E5011147a/7811cbf26bf0ab1a.jpg.avif"
                    alt=""></li>
            <li><img src="https://img14.360buyimg.com/n5/jfs/t1/61224/5/18019/60823/628ddbb2E72a14ecf/1b827f67b2b2c4f2.jpg.avif"
                    alt=""></li>
            <li><img src="https://img14.360buyimg.com/n5/jfs/t1/146777/5/27557/100428/628ddbb3Eced4b70a/784a2aaa54bd9417.jpg.avif"
                    alt=""></li>
            <li><img src="https://img14.360buyimg.com/n5/jfs/t1/38555/39/19176/66455/6335ccfcE492fb9a6/729aa1905c16c873.jpg.avif"
                    alt=""></li>
        </ul>
    </div>
    <script>
        // 鼠标移到哪个图片就改变大图片
        // 获取li
        let lis = document.querySelectorAll('li');
        // 获取大图片
        let bigImg = document.querySelector('.big-img>img');


        // 排他思想
        function clearBorder() {
            for (let i = 0; i < lis.length; i++) {
                const element = lis[i];
                element.className = ''
            }
        }
        // 事件处理程序
        function mouseHover() {
            // 获取当前li的里面的图片
            let curImg = this.querySelector('img');
            // 大图的src等于当前图片的src
            bigImg.src = curImg.src;
            // 先清除再添加
            clearBorder();
            this.className = 'cur-img'
        }

        for (let i = 0; i < lis.length; i++) {
            const element = lis[i];
            // 鼠标移上事件
            element.addEventListener('mousemove', mouseHover);
        }

    </script>
</body>

</html>